package com.example.lol.adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.fragment.app.FragmentStatePagerAdapter;

import com.example.lol.ui.fragment.HaoyouFragment;
import com.example.lol.ui.fragment.SaishiFragment;
import com.example.lol.ui.fragment.YundingFragment;

public class MyFragmentPagerAdapter  extends FragmentStatePagerAdapter {
    private String[] mTitles = new String[]{"关注", "推荐", "赛事","云顶","手游","视屏","电视台","活动"};

    public MyFragmentPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 1) {
            return new HaoyouFragment();
        } else if (position == 2) {
            return new SaishiFragment();
        }else if (position==3){
            return new YundingFragment();
        }
        else if (position==4){
            return new HaoyouFragment();
        }
        else if (position==5){
            return new HaoyouFragment();
        }
        else if (position==6){
            return new HaoyouFragment();
        }
        return new HaoyouFragment();
    }

    @Override
    public int getCount() {
        return mTitles.length;
    }

    //ViewPager与TabLayout绑定后，这里获取到PageTitle就是Tab的Text
    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles[position];
    }
}

